package junior;

import javax.swing.*;
import java.beans.IntrospectionException;
import java.util.*;

/**
 *
 */
public class 测试 {

    static int[] a;
    static int startIndex;
    static List<Integer> list;
    public static void main(String[] args) {
        a = new int[]{1, 2, 1};
        startIndex = 0;
        list = new ArrayList<>();
        Arrays.sort(a);
        System.out.println("Arrays.toString(a) = " + Arrays.toString(a));
        dfs(0);

    }
    public static void dfs(int startIndex){
        if(list.size() == a.length-1){
            System.out.println("list.toString() = " + list.toString());
            return;
        }
        for (int i = startIndex; i < a.length; i++) {
            if(i > startIndex && a[i-1] == a[i]){
                continue;
            }
            list.add(a[i]);
            dfs(i+1);
            list.remove(list.size()-1);

        }

    }
}
